package com.drojian.demo1.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.drojian.demo.R;

import java.util.ArrayList;
import java.util.List;

public class MyViewPage2Adapter extends RecyclerView.Adapter<MyViewPage2Adapter.myViewHolder> {

    private List<String> title = new ArrayList<>();

    public MyViewPage2Adapter() {
        title.add("1");
        title.add("2");
        title.add("3");
        title.add("4");
        title.add("5");
        title.add("6");
        title.add("7");

    }
    @NonNull
    @Override
    public myViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new myViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.ui4_viewpage2_item,parent,false));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewPage2Adapter.myViewHolder holder, int position) {
        holder.mTv.setText(title.get(position));
    }


    @Override
    public int getItemCount() {
        return title.size();
    }

    class myViewHolder extends RecyclerView.ViewHolder {
        TextView mTv;
        RelativeLayout mContainer;
        public myViewHolder(@NonNull View itemView) {
            super(itemView);
            mTv = itemView.findViewById(R.id.tvTitle);
            mContainer = itemView.findViewById(R.id.container);
        }
    }
}
